import axios from "axios";
import store from "@/store"
const request = axios.create({
  baseURL: process.env.VUE_APP_API1,
  timeout: 10000,
  headers: {},
});

request.interceptors.request.use((config) => {
  console.log(store.state.user.userTempId,"store.state.user.userTempId");
  config.headers.userTempId = store.state.user.userTempId;
  config.headers.token = store.state.user.token;
  return config;
});

request.interceptors.response.use(
  (response) => {
    if (response.data.code === 200) {
      return response.data.data;
    } else {
      return Promise.reject(response.data);
    }
  },
  (err) => {
    return Promise.reject(err);
  }
);

export default request;

